package com.xuecheng.api.client.fallback;

import com.xuecheng.api.client.ContentClient;
import com.xuecheng.api.dto.CoursePublish;
import com.xuecheng.api.dto.TeachPlanAndMediaDTO;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;

/**
 * @author 勾新杰
 * @version 1.0
 * @description: 课程服务客户端降级逻辑
 * @date 2025/2/26 13:18
 */
@Slf4j
public class ContentClientFallBackFactory implements FallbackFactory<ContentClient> {
    @Override
    public ContentClient create(Throwable throwable) {
        return new ContentClient() {

            /**
             * 根据课程id查询课程发布信息
             *
             * @param courseId 课程id
             * @return 课程发布信息
             */
            @Override
            public CoursePublish getById(Long courseId) {
                log.error("调用content服务查询课程发布信息失败，降级逻辑触发");
                return null;
            }

            /**
             * 根据课程计划id查询课程媒资信息
             *
             * @param teachplanId 课程计划id
             * @return 课程媒资信息
             */
            @Override
            public TeachPlanAndMediaDTO getTeachPlanAndMedia(Long teachplanId) {
                log.error("调用content服务查询课程计划媒资信息失败，降级逻辑触发");
                return null;
            }
        };
    }
}
